<template>
  <div class="body-content">
    <div id="magazine" v-if="bookImgs && bookImgs.length">
      <div v-for="(item, index) in bookImgs" :key="index">
        <div class="page" v-if="isShow">
          <img class="img_full" :src="item.img" alt="" />
        </div>
      </div>
    </div>
    <div id="magazine" v-else>
      <div class="page" v-if="isShow">
        <img src="" alt="" />
      </div>
    </div>
    <!-- <div v-show="!isShow" class="loading_box">
      <div class="loading">
        <spinner />
      </div>
    </div> -->
  </div>
</template>
<script>
import $ from "jquery";
import turn from "../plugin/turn/lib/turn";
import Spinner from 'vue-simple-spinner'

export default {
  name: "TurnCom",
  components: { Spinner },
  props: {
    bookImgs: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      isShow: false,
      value: "",
      page: 1
    };
  },
  mounted() {
    setTimeout(() => {
      this.isShow = true;
      $("#magazine").turn("center");
      $("#magazine").turn("page");

      this.initTurn();
    }, 1000);
  },

  methods: {
    initTurn() {
      let self = this;
      $("#magazine").turn({
        display: "double",
        elevation: 0, // 转换期间页面的高度
        duration: 1200,
        gradients: true,
        autoCenter: true,
        acceleration: true,
        page: self.page,
        // width: 600
      });
    },
  },
};
</script>
<style lang="less" scoped>
body {
  background: #ccc;
}
.body-content {
  padding: 20px 0;
}
.page {
  width: 100%;
}
.current-page {
  position: absolute;
  bottom: 0;
  width: 100%;
  text-align: center;
  font-size: 14px;
}

#magazine.shadow {
  -webkit-box-shadow: 0 4px 10px #666;
  -moz-box-shadow: 0 4px 10px #666;
  -ms-box-shadow: 0 4px 10px #666;
  -o-box-shadow: 0 4px 10px #666;
  box-shadow: 0 4px 10px #666;
}

#magazine .turn-page {
  background-color: #ccc;
  background-size: 100% 100%;
}
.bookmark {
  font-size: 20px;
  writing-mode: tb-rl;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.item:nth-child(2n) {
  background: #ccc;
  width: 45px;
  height: 50px;
}
.item {
  width: 45px;
  height: 160px;
  background: red;
}
.item:nth-child(1) {
  z-index: 4;
  text-shadow: 6px 6px 6px #999;
}
.item:nth-child(2) {
  z-index: 3;
  text-shadow: 6px 6px 6px #333;
}
.item:nth-child(3) {
  z-index: 2;
  text-shadow: 6px 6px 6px #333;
}
.item:nth-child(4) {
  z-index: 1;
  text-shadow: 6px 6px 6px #333;
}

.loading_box {
  width: 100%;
  height: 100%;
  position: relative;
  top: -500px;

  .loading {
    font-size: 60px;
    position: absolute;
    color: #ccc !important;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

@media screen and (min-width: 1600px) {
  .page { height: 700px; }
  #magazine { width: 1090px !important; height: 700px; }
}

@media screen and (min-width: 1400px) and (max-width: 1599px) {
  .page { height: 650px; }
  #magazine { width: 1000px !important; height: 650px; }
}

@media screen and (min-width: 1200px) and (max-width: 1399px) {
  .page { height: 600px; }
  #magazine { width: 900px !important; height: 600px; }
}

@media screen and (min-width: 1000px) and (max-width: 1299px) {
  .page { height: 550px; }
  #magazine { width: 800px !important; height: 550px; }
}

@media screen and (min-width: 768px) and (max-width: 999px) {
  .page { height: 500px; }
  #magazine { width: 700px !important; height: 500px; }
}
</style>